package com.cy.pj.common.controller;

import com.cy.pj.common.pojo.Response;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Min;

@Validated
@RestController
public class ArcController {
    @RequestMapping("/doComput/{n1}/{n2}")
    public String doCompute(@PathVariable @Min(value = 1, message = "can't be 0") Integer n1, @PathVariable Integer n2) {
        Integer div = n1 / n2;
        return "div is" + div;

    }

    @RequestMapping("doyou")
    public String doyou(@Validated Response response, BindingResult bindingResult) {
        if (bindingResult.hasErrors()) {
            return "fail";
        }
        return "success";
    }
}
